package com.lesso.yjy.sunflower.domain.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.lesso.yjy.sunflower.domain.repository.AttendanceRecordRepository;
import com.lesso.yjy.sunflower.infra.assembler.AttendanceRecordAssembler;
import com.lesso.yjy.sunflower.pojo.dto.AttendanceRecordDTO;
import com.lesso.yjy.sunflower.pojo.dto.AttendanceRecordQueryDTO;
import com.lesso.yjy.sunflower.pojo.vo.AttendanceRecordVO;
import org.springframework.stereotype.Service;

@Service
public class AttendanceRecordDomainService {
    private final AttendanceRecordRepository attendanceRecordRepository;

    public AttendanceRecordDomainService(AttendanceRecordRepository attendanceRecordRepository){
        this.attendanceRecordRepository = attendanceRecordRepository;
    }

    public Long save(AttendanceRecordDTO dto) {
        return attendanceRecordRepository.save(AttendanceRecordAssembler.INSTANCE.dtoToEntity(dto));
    }

    public Page<AttendanceRecordVO> page(AttendanceRecordQueryDTO dto) {
        return attendanceRecordRepository.getPageList(dto);
    }

    public Page<AttendanceRecordVO> customPage(AttendanceRecordQueryDTO dto) {
        return attendanceRecordRepository.getCustomPageList(dto);
    }

    public void deleteById(Long id) {
        attendanceRecordRepository.removeById(id);
    }

    public void update(AttendanceRecordDTO dto) {
        attendanceRecordRepository.updateById(dto);
    }
}
